package com.poly.system;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.poly.common.core.constant.SecurityConstants;
import com.poly.common.core.constant.ServiceNameConstants;
import com.poly.common.core.domain.R;
import com.poly.system.domain.SysUser;
import com.poly.system.factory.RemoteUserFallbackFactory;
import com.poly.system.model.LoginUser;

import java.util.List;
import java.util.Map;

/**
 * 用户服务
 *
 * @author Yang huijing
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 获取用户信息
     * @param userId
     * @return
     */
    @GetMapping("/user/getUserById")
    R<SysUser> getUserById(@RequestParam(value = "userId") Long userId);

    @GetMapping("/user/getUserList")
    R<List<SysUser>> getUserList(@RequestParam(value = "nickName") String NickName,@RequestParam(value = "deptId") String deptId);



    /**
     * 获取用户名称
     * @param idList
     * @return
     */
    @PostMapping("/user/getUserNameMap")
    R<Map<Long,String>> getUserNameMap(@RequestBody List<Long> idList);

    /**
     * 获取用户列表
     * @param idList
     * @return
     */
    @PostMapping("/user/getUserListByIdList")
    R<List<SysUser>> getUserListByIdList(List<Long> idList);


    /**
     * 获取缓存用户列表
     *
     * @param userIdList
     * @return
     */
    @PostMapping("/user/getCacheUserList")
    R<List<SysUser>> getCacheUserById(@RequestBody List<Long> userIdList);

    /**
     * 获取缓存用户名称
     *
     * @param userIdList
     * @return
     */
    @PostMapping("/user/getCacheUserName")
    R<String> getCacheUserName(@RequestBody List<Long> userIdList);
}
